#pragma once
#include "JeayeSDK.h"

#ifdef _DEBUG
#ifndef _ASSERT
#include <assert.h>
#define _ASSERT assert
#endif
#else
#ifndef _ASSERT
#define _ASSERT
#endif
#endif

#ifndef _C_L
#define _C_L(x) __C_L(x)
#define __C_L(x) L##x
#endif

#define C_ERR_BUFFER_SIZE    1024

#ifdef _DEBUG
JEAYESDK_API void DebugOutA(LPCSTR fmt, ...);
JEAYESDK_API void DebugOutW(LPCTSTR fmt, ...);
JEAYESDK_API void c_debugOutA(const char *file, const INT32 line, const char *func, const char *fmt, ...);
JEAYESDK_API void c_debugOutW(const wchar_t *file, const INT32 line, const wchar_t *func, const wchar_t *fmt, ...);

#ifdef _MSC_VER
#define C_ERROR_LOGW(FMT,...) c_debugOutW(_C_L(__FILE__), __LINE__, _C_L(__FUNCDNAME__), FMT, ## __VA_ARGS__)
#define C_ERROR_LOGA(FMT,...) c_debugOutA(__FILE__, __LINE__, __FUNCDNAME__, FMT, ## __VA_ARGS__)
#else
#define CC_ERROR_LOGW(FMT,ARGS...) c_debugOutW(_CC_L(__FILE__), __LINE__, _CC_L(__FUNCDNAME__), FMT, ##ARGS)
#define CC_ERROR_LOGA(FMT,ARGS...) c_debugOutA(__FILE__, __LINE__, __FUNCDNAME__, FMT, ##ARGS)

#endif /*end ifdef CC_WINDOWS*/

#ifdef _UNICODE
#define DebugOut DebugOutW
#define C_DebugOut c_debugOutW
#define C_ERROR_LOG C_ERROR_LOGW
#else
#define DebugOut DebugOutA
#define C_DebugOut c_debugOutA
#define C_ERROR_LOG C_ERROR_LOGA
#endif

#else
inline void DebugOut(LPCTSTR fmt, ...) {}
#define C_ERROR_LOG DebugOut
#endif